package com.joolun.mall.handle;

import com.joolun.common.core.domain.AjaxResult;
import com.joolun.mall.dto.JDCancelOrderResultDTO;
import com.joolun.mall.dto.JDFreightResultDTO;
import com.joolun.mall.entity.UserAddress;
import com.joolun.mall.enums.LogisticsEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author quyang
 * @description 物流抽象类
 * @date 2022/1/2
 */
@Slf4j
@Component
public abstract class LogisticsAbstractHandler {

    public LogisticsAbstractHandler getInstance(Integer logisticsId) {
        LogisticsAbstractHandler logisticsHandler = this;
        if (LogisticsEnum.JD.getType().equals(logisticsId)) {
            logisticsHandler = new JDLogisticsHandler();
        }else if (LogisticsEnum.SF.getType().equals(logisticsId)){
            logisticsHandler= new SFLogisticsHandler();
        }
        return logisticsHandler;
    }

    /**
     * 运费查询
     *
     * @param senderAddress 发件地址
     * @param receiverAddress 收件地址
     * @param weight 重量(KG)
     * @return
     */
    public List<JDFreightResultDTO> freight(UserAddress senderAddress, UserAddress receiverAddress, Integer weight) {
        return null;
    }

    public abstract AjaxResult delivery(UserAddress senderAddress, UserAddress receiverAddress, Integer weight, String orderId, String channelCode);

    /**
     * 取消运单
     * @param deliveryNo 运单号
     * @return
     */
    public JDCancelOrderResultDTO cancelOrder(String deliveryNo){
        return null;
    }
}
